<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>委托管理</title>
		<link rel="stylesheet" href="/fk-acti/resource/extjs6.0/classic/theme-crisp/resources/theme-crisp-all.css"></link>
		<script src="/fk-acti/resource/extjs6.0/ext-all.js"></script>
		<script src="/fk-acti/resource/extjs6.0/classic/locale/locale-zh_CN.js"></script>
		<script type="text/javascript" src="/fk-acti/web/resource/js/app.js"></script>
		<link rel="stylesheet" href="/fk-acti/web/resource/css/app.css"></link>
		<script type="text/javascript">
			var dataStore;
			var buttonCode; //用于actioncolumn列编辑，删除按钮的显示
			dataStore = Ext.create("Ext.data.Store", {
				autoLoad: true,
				pageSize: 15,
				sorters: {
					property: "created",
					direction: "DESC"
				},
				proxy: {
					type: "ajax",
					url: "/fk-acti/delegate/list",
					reader: {
						type: "json",
						root: "result.list",
						totalProperty: "result.pagination.total"
					}
				},
				listeners: {
					"beforeload": function(store, op, options) {
						var params = searchFormPanel.getForm().getValues();
						Ext.apply(dataStore.proxy.extraParams, params);
					}
				}
			}); //#dataStore

			var searchFormPanel = Ext.create("Ext.form.Panel", {
				width: "100%",
				frame: true,
				title: "搜索条件",
				style: {
					marginBottom: "5px"
				},
				bodyStyle: {
					padding: "10px"
				},
				buttonAlign: "center",
				collapsible: true,
				defaultType: "textfield",
				items: [{
					xtype: "container",
					layout: "hbox",
					items: [
						{
							fieldLabel: "委托业务",
							labelAlign: "right",
							xtype: "textfield",
							emptyText: "请选择委托业务",
							name: "business",
							margin: "10px"
						},
						{
							xtype: "combo",
							labelAlign: "right",
							fieldLabel: "委托人",
							emptyText: "请选择委托人姓名",
							name: "user",
							editable: false,//是否可编辑
							lazyInit: false,//延时初始化下拉列表，默认为true
							triggerAction: 'all',
							valueField: 'value',
							margin: "10px",
							store: new Ext.data.ArrayStore({
								fields: ['value', 'text'],
								data: [
										["1", "张三"],
										["0", "李四"]
								],
							}),
						},
						{
							fieldLabel: "开始时间",
							labelAlign: "right",
							xtype: "datefield",
							format: "Y-m-d",
							editable: false,
							emptyText: "委托开始时间",
							name: "start",
							margin: "10px"
						},
						{
							fieldLabel: "结束时间",
							labelAlign: "right",
							xtype: "datefield",
							format: "Y-m-d",
							editable: false,
							emptyText: "委托结束时间",
							name: "end",
							margin: "10px"
						},
					]
				}, ],
				buttons: [{
					text: "搜索",
					icon: jcapp.getIcon("magnifier.png"),
					handler: function() {
						dataStore.reload();
					}
				}, {
					text: "重置",
					icon: jcapp.getIcon("arrow_refresh.png"),
					handler: function() {
						this.up("form").getForm().reset();
					}
				}]
			}); //#searchFormPanel

			var listGridPanel = Ext.create("Ext.grid.Panel", {
				title: "委托管理列表",
				tbar: [{
							text: "新增",
							xtype: "button",
							icon: jcapp.getIcon("add.png"),
							handler: function() {
								myAdd();
							}
						}
				],
				dockedItems: [{
					xtype: "pagingtoolbar",
					store: dataStore, // same store GridPanel is using
					dock: "bottom",
					displayInfo: true
				}],
				store: dataStore,
				viewConfig:{enableTextSelection:true},
				columns: [{
						header: "序号",
						xtype: "rownumberer",
						width: 60,
						align: "center"
					},
					{
						text: "kid",
						dataIndex: "kid",
						flex: 1,
						xtype: "hidden"
					},
					{
						text: "委托业务",
						dataIndex: "business",
						flex: 1
					},
					{
						text: "委托人",
						dataIndex: "user",
						flex: 1
					},
					{
						text: "被委托人",
						dataIndex: "userd",
						flex: 1
					},
					{
						text: "委托开始时间",
						dataIndex: "start",
						flex: 1,
						renderer: function(value) {
							return Ext.util.Format.date(new Date(parseInt(value)),"Y-m-d");
						}
					},
					{
						text: "委托结束时间",
						dataIndex: "end",
						flex: 1,
						renderer: function(value) {
							return Ext.util.Format.date(new Date(parseInt(value)),"Y-m-d");
						}
					},
					{
						text: "委托原因",
						dataIndex: "reason",
						flex: 1
					},
					{
						text: "委托状态",
						dataIndex: "statuz",
						flex: 1
					},
					{
						xtype: "actioncolumn",
						width: 100,
						align: "center",
						text: '工作流操作',
						items: [{
								xtype: 'button',
								tooltip: '委托历史',
								icon: jcapp.getIcon("application_view_detail.png"),
								handler: function(grid, rowIndex, colIndex) {
									
								}
							}
						]
					},
					{
						xtype: "actioncolumn",
						width: 100,
						align: "center",
						text: '操作',
						items: [{
								xtype: 'button',
								tooltip: '编辑',
								icon: jcapp.getIcon("application_form_edit.png"),
								handler: function(grid, rowIndex, colIndex) {
									var rec = grid.getStore().getAt(rowIndex);
									var kid = rec.get('kid');
									myEdit(kid);
								}
							},
							{
								xtype: "container"
							},
							{
								xtype: 'button',
								tooltip: '删除',
								icon: jcapp.getIcon("cross.png"),
								handler: function(grid, rowIndex, colIndex) {
									var rec = grid.getStore().getAt(rowIndex);
									var kid = rec.get('kid');
									myDel(kid);
								}
							}
						]
					}
				]
			}); //#listGridPanel

			Ext.onReady(function() {
				searchFormPanel.render(Ext.getBody());
				listGridPanel.render(Ext.getBody());
			});
		</script>
	</head>
	<body>
	
	</body>
	<script type="text/javascript" src="./add.js"></script>
	<script type="text/javascript" src="./edit.js"></script>
	<script type="text/javascript" src="./delete.js"></script>
</html>